<?php
/**
 * CEOfox
 *
 * @copyright  Copyright 2011-2012 CEOfox, Inc.
 * @license    http://ceofox.com/pages/license
 * @version    $Id: notifications.class.php 17086 2013-05-24 09:40:17 $
 * @author     CEOfox, Inc.
 */
?>
<?php
defined('PHPFOX') or exit('NO DICE!');
class Follow_Component_Block_Notifications extends Phpfox_Component
{
    public function process()
    {
        if(!Phpfox::isUser())
        {
            return false;
        }
        $iPage = $this->getParam('page', 1);
        $iPageSize = $this->getParam('page_size', 5);
        $oNotification = Phpfox::getService('follow.notifications');
        $iNewestId = $this->getParam('newest-id', -1);
        $bIsReload = $this->getParam('reload', false);
        
        $aNotifications = $oNotification->getNotifications(Phpfox::getUserId(), $iPage, $iPageSize, $iNewestId);
        $sCloseIcon =  Phpfox::getParam('core.path').'theme/frontend/default/style/default/image/misc/delete_hover.gif';
        if(!count($aNotifications))
        {
            return false;
        }
        $this->template()->assign(array(
            'aNotifications' => $aNotifications,
            'sHeader' => Phpfox::getPhrase('follow.notifications'),
            'sCoreUrl' => Phpfox::getParam('core.path'),
            'iTimeOut' => Phpfox::getParam('follow.refresh_notification'),
            'iNewestId' => isset($aNotifications) ? $aNotifications[0]['notification_id'] : $iNewestId,
            'bIsReload' => $bIsReload,
            'sCloseIcon' => $sCloseIcon,
            'iCnt' => count($aNotifications),
            'sJsonNotifications'=> json_encode($aNotifications),
            'aFooter' => array(
                    Phpfox::getPhrase('follow.see_all_notifications') => $this->url()->makeUrl('follow.notification')
                )
        ));
        return 'block';
    }
}


?>
